package com.huakang.controller;

import com.huakang.entity.Record;
import com.huakang.service.RecordService;
import com.huakang.utils.RecordVo;
import com.huakang.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping(value = "/record")
public class RecordController {
    @Autowired
    RecordService recordService;
    @GetMapping("/findPid")
    public ResultVo findPid(Integer pid){
        List<RecordVo> list=recordService.findPid(pid);
        return ResultVo.success("成功",list);
    }
    @PostMapping("/insert")
    public ResultVo findPid(@RequestBody RecordVo recordVo){
        Date date=new Date();
        date.setDate(date.getDate()+1);
        Record record=new Record(null,date,recordVo.getRdnum(),recordVo.getMedid(),recordVo.getInpid());
        boolean b=recordService.insert(record);
        if(b){
            return ResultVo.success("成功");
        }
        return  ResultVo.fail("失败");
    }
}
